class Ball():
    def __init__(self, screen, ai_settings):
        self.screen = screen
        self.radius = 5
        self.ai_settings = ai_settings
        self.color = (100, 100, 100)
        self.pos = [600.5, 340]
        self.speedx = 0  # speed of existence
        self.speedy = 0
        self.ax = 2  # The speed of the ball as it moves
        self.ay = 2
        self.beKeep = False  # Confirm whether the ball is held
        # Set the direction of the ball
        self.dL = False
        self.dR = False
        self.dU = False
        self.dD = False

    # Clear the pointing state of the ball
    def emptyStatus(self):
        self.dL = False
        self.dR = False
        self.dU = False
        self.dD = False

    #The ball is received and stops moving
    def update(self):
        if self.beKeep==True:
            self.speedx=0
            self.speedy=0

    # Judge whether to score a goal
    def ShootGoal(self):
        x, y = self.pos[0], self.pos[1]
        if 310 <= y <= 378 and (1092 >x > 1072 or 108 <x < 127):
            return True
